/*
 * @Author: your name
 * @Date: 2021-10-07 09:26:37
 * @LastEditTime: 2021-10-07 09:46:15
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \common-vue\src\utils\create.js
 */

import Vue from 'vue'

export function create(Component, props) {
  const vm = new Vue({
    render: h => {
      return h(Component, { props })
    }
  })
  // 挂载 获取dom
  vm.$mount()
  document.body.appendChild(vm.$el)
  // 获取组件实例
  const comp = vm.$children[0]

  comp.remove = () => {
    document.body.removeChild(vm.$el)
    vm.$destroy()
  }
  return comp
}
